﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Ketnoidulieu
{
    public partial class frmLabel : Form
    {
        public frmLabel()
        {
            InitializeComponent();
        }

        clssQLDiem obj = new clssQLDiem();
        DataSet ds = new DataSet();

        private void frmLabel_Load(object sender, EventArgs e)
        {
            ds = obj.laydulieu1();
            hienthitext(0);
        }

        void hienthitext(int vitri)
        {
            DataRow dr = ds.Tables[0].Rows[vitri];
            txtmasv.Text = dr["MaSV"].ToString();
            txttensv.Text = dr[1].ToString();
            txtmalop.Text = dr[6].ToString();
            txtngaysinh.Text = dr[3].ToString();
            lbldong.Text = "Dòng:" + (vitri+1).ToString() + "/" + ds.Tables[0].Rows.Count.ToString();
        }
        int vitri = 0;

        private void btncuoi_Click(object sender, EventArgs e)
        {
            vitri = ds.Tables[0].Rows.Count - 1;
            btncuoi.Enabled = false;
            btnsau.Enabled = false;
            btndau.Enabled = true;
            btntruoc.Enabled = true;
            hienthitext(vitri);
        }

        private void btnsau_Click(object sender, EventArgs e)
        {
            vitri++;
            if (vitri == ds.Tables[0].Rows.Count-1)
            {
                btnsau.Enabled = false;
                btncuoi.Enabled = false;
                hienthitext(vitri);
            }
            else
            {
                btndau.Enabled = true;
                btntruoc.Enabled = true;
                hienthitext(vitri);
            }
        }

        private void btntruoc_Click(object sender, EventArgs e)
        {
            vitri--;
            if (vitri == 0)
            {
                btntruoc.Enabled = false;
                btndau.Enabled = false;
                hienthitext(vitri);
            }
            else
            {
                btnsau.Enabled = true;
                btncuoi.Enabled = true;
                hienthitext(vitri);
            }
        }

        private void btndau_Click(object sender, EventArgs e)
        {
            vitri = 0;
            btncuoi.Enabled = true;
            btnsau.Enabled = true;
            hienthitext(vitri);
            btndau.Enabled = false;
            btntruoc.Enabled = false;
        }
    }
}
